package com.wx.app.card.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wx.app.card.dao.entity.StageEntity;
import com.wx.app.card.dao.entity.StageRecordDetailEntity;
import com.wx.app.card.dao.entity.StageRecordEntity;
import com.wx.app.card.dao.mapper.StageMapper;
import com.wx.app.card.dao.mapper.StageRecordDetailMapper;
import com.wx.app.card.dao.mapper.StageRecordMapper;
import com.wx.app.card.domain.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类功能描述：
 *
 * @author：刘富国
 * @createTime：2019/7/30 19:43
 */
@Api(tags = "D期数描述")
@Slf4j
@RestController
public class StageController extends BaseController {

    @Autowired
    private StageMapper stageMapper;
    @Autowired
    private StageRecordMapper stageRecordMapper;
    @Autowired
    private StageRecordDetailMapper stageRecordDetailMapper;


    /**
     * 获取期数列表
     */
    @ApiOperation(value = "1获取期数列表")
    @PostMapping("/stage/list")
    public Result stageList(@RequestHeader String token) {
        return success(stageMapper.selectList(new QueryWrapper<StageEntity>().orderByAsc("stage_sort")));
    }

    /**
     * 获取期数记录列表
     */
    @ApiOperation(value = "2获取期数记录列表")
    @PostMapping("/stage/record/list")
    public Result stageRecordList(@RequestHeader String token, String stageId) {
        return success(stageRecordMapper.selectList(new QueryWrapper<StageRecordEntity>()
                .eq("stage_id", stageId)
                .orderByAsc("record_sort")));
    }

    /**
     * 获取期数详情列表
     */
    @ApiOperation(value = "3获取期数详情列表")
    @PostMapping("/stage/record/detail")
    public Result stageRecordDetailList(@RequestHeader String token, String recordId) {
        return success(stageRecordDetailMapper.selectList(new QueryWrapper<StageRecordDetailEntity>()
                .eq("record_id", recordId)
                .orderByAsc("detail_sort")));
    }


}
